package Utils;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

/**
 * @author zyp
 * date 2022-03-08
 */
public class DBUtils {
    private static String Driver = "com.mysql.jdbc.Driver";
    private static String url = "jdbc:mysql://localhost:3306/blog?characterEncoding=utf8&useSSL=true&serverTimezone=GMT";
    private static String username = "root";
    private static String password = "123456";

    public static Connection getConnection() {
        try {
            Class.forName(Driver);
            Connection connection = DriverManager.getConnection(url, username, password);
            return connection;
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        } catch (SQLException e) {
            e.printStackTrace();
        }

        return null;
    }
}
